package com.kb.erp.entity.quote;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Data
public class IqcProduct {
    private String supplier;
    private long sku;
    private String proName;
    private String proMaf;
    private String proDesc;
    private String dateCode;
    private int stock;
    private int moq;
    private int spq;
    private List<Double> rmb;
    private List<Double> usd;
    private List<Integer> nums;
    private String leadTimeCn;
    private List<String> dataSheet;
    private String footprint;
    private String cateName;
    private int mpq;
    private String imgUrl;
    private String detailUrl;
    private String isCwh;
    @JsonProperty(value = "package")
    private String packageValue; // Assuming `package` is a string
    public String getRmbAsString(String currency) {
        if(Objects.equals(currency, "USD")){

            if (usd == null || usd.isEmpty()) {
                return "";
            }
            return usd.stream()
                    .map(String::valueOf)
                    .collect(Collectors.joining("<br/>"));
        }


        if (rmb == null || rmb.isEmpty()) {
            return "";
        }
        return rmb.stream()
                .map(String::valueOf)
                .collect(Collectors.joining("<br/>"));
    }

    // Method to convert nums to a <br/> separated string
    public String getNumsAsString() {
        if (nums == null || nums.isEmpty()) {
            return "";
        }
        return nums.stream()
                .map(String::valueOf)
                .collect(Collectors.joining("<br/>"));
    }

}
